package flc.ast.adapter;

import android.graphics.Color;
import android.view.View;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import flc.ast.R;
import flc.ast.bean.ColorBean;
import stark.common.basic.adaptermutil.StkProviderMultiAdapter;
import stark.common.basic.adaptermutil.StkSingleSpanProvider;
import stark.common.basic.view.container.StkRelativeLayout;

public class ColorAdapter extends StkProviderMultiAdapter<ColorBean>{

    public ColorAdapter() {
        addItemProvider(new StkSingleSpanProvider<>(32));
        addItemProvider(new ColorProvider());
    }

    private class ColorProvider extends BaseItemProvider<ColorBean> {
        @Override
        public int getItemViewType() {
            return StkProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_color;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, ColorBean bean) {
            StkRelativeLayout view = baseViewHolder.getView(R.id.rlColorItem);
            view.setBackgroundColor(Color.parseColor(bean.getColor()));
            if (bean.isSelect()){
                baseViewHolder.getView(R.id.llColorItemSel).setVisibility(View.VISIBLE);
            }else{
                baseViewHolder.getView(R.id.llColorItemSel).setVisibility(View.GONE);
            }
        }
    }

}
